package com.ccys.app.controller;

import com.ccys.common.vo.ResponseResultApp;
import com.ccys.db.cache.UserUtil;
import com.ccys.db.mapper.TblSupplierMapper;
import com.ccys.db.vo.app.deliveryAddress.GetDeliveryAddressInfoVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author：XLY
 * @Date：2024/1/26 0026
 */
@RestController
@RequestMapping("/deliveryAddressSelectScreen")
@Api(tags = "Delivery Address Select Screen")
public class DeliveryAddressSelectScreenController {


    @Resource
    private TblSupplierMapper mapper;

    @ApiOperation("Delivery Address Select Screen/ 1")
    @GetMapping("GetDeliveryAddressInfo")
    public ResponseResultApp<GetDeliveryAddressInfoVo> getDeliveryAddressInfo(HttpServletRequest request) {
        String curLoginUserId = UserUtil.getCurLoginUserId();
        List<GetDeliveryAddressInfoVo.DeliveryAddressVo> addressInfo = mapper.getDeliveryAddressInfo(curLoginUserId);
        PageInfo<GetDeliveryAddressInfoVo.DeliveryAddressVo> pageInfo = new PageInfo<>(addressInfo);
        GetDeliveryAddressInfoVo vo = new GetDeliveryAddressInfoVo();
        vo.setDeliveryAddress(addressInfo);
        vo.setTotalPage(pageInfo.getPages());
        return ResponseResultApp.success(vo);
    }
}
